var Cart_page = {
    initproDownList : function (configArray) {
        //获取Select菜单
        //  ____configArray=configArray;
        //  var existArray=configArray.split("|");
    	$('div[tag1="sp"]').each(function() {
            var selectObj = $(this).find('select');
            var spanObj = $(this).find('span');
            var ulObj = $(this).find('ol');
            ulObj.html('');
            selectObj.find('option').each(function(idx) {
            	ulObj.append('<li currentIndex='+ idx +'">'+ this.text +'</li>');
            });
            ulObj.find('li').click(function() {
            	spanObj.html($(this).html());
            	selectObj[0].selectedIndex = parseInt($(this).attr('currentIndex'));
            	selectObj.change();
            	ulObj.removeClass('show');
                var params = this.parentNode.parentNode.id.split("_");
                if (params.length >= 3) {}            	
            }).hover(function() {
            	this.className = 'over';
            }, function() {
            	this.className = '';
            });
            spanObj.click(function() {
            	if ($(this).closest('dl').find('.span-delete:visible').size()==1) return;
                //如果当前是显示的，就隐藏，反之亦然
            	if (ulObj.hasClass('show')) {
            		ulObj.removeClass('show');
            	} else {
            		ulObj.addClass('show');
            	}
            }).hover(function() {
                this.className = 'over';            	
            }, function() {
                this.className = '';            	
            });
            this.onclick = function (event) {
                if (!event) {
                    event = window.event;
                }
                //阻止事件冒泡
                event.cancelBubble = true;
                var eventUlObj = this.getElementsByTagName("ol")[0];
                Cart_page.bodyClickHiddenUl(eventUlObj);
            }
    	});
    },
    selectCurrentItem : function (ulObj, currentObj) {
		var parentObj = ulObj.parentNode;
		var spanObj = parentObj.getElementsByTagName("span")[0];
		spanObj.firstChild.nodeValue = currentObj.firstChild.nodeValue;
		var selectObj = parentObj.getElementsByTagName("select")[0];
		selectObj.selectedIndex = parseInt(currentObj
				.getAttribute("currentIndex"));
		
		if (selectObj.fireEvent)  
			selectObj.fireEvent("onchange") ; 
		  else if (selectObj.onchange!=null)
			  selectObj.onchange(selectObj);
	},
	showHiddenUl : function (currentObj) {
		var parentNode = currentObj.parentNode;
		var ulObj = parentNode.getElementsByTagName("ol")[0];
		if (ulObj.className == "") {
			ulObj.className = "show";
		} else {
			ulObj.className = "";
		}
	},
	//点击body区域（非"下拉菜单"）隐藏菜单
	addBodyClick : function (func) {
		var bodyObj = document.getElementsByTagName("body")[0];
		var oldBodyClick = bodyObj.onclick;
		if (typeof bodyObj.onclick != 'function') {
			bodyObj.onclick = func;
		} else {
			bodyObj.onclick = function() {
				oldBodyClick();
				func();
			}
		}
	},
	//隐藏所有的OL
	bodyClickHiddenUl : function (eventUlObj) {
		//var existArray = ____configArray.split("|");
		var existDiv = $('div[tag1="sp"]');
		var existArray = new Array();
		for (var i = 0; i < existDiv.length; i++) {
			existArray[i] = existDiv[i].id;
		}
		for ( var i = 0; i < existArray.length; i++) {
			if (existArray[i].length < 1) {
				return;
			}
			//寻找所有OL并且隐藏
			var parentContainer = document.getElementById(existArray[i]);
			if (!parentContainer) {
				return;
			}
			var ulObj = parentContainer.getElementsByTagName("ol");
			if (eventUlObj != ulObj[0]) {
				ulObj[0].className = "";
			}
		}
	},
	DoMenu : function (emid) {
		var LastLeftID = "";
		$(".dev_cart_act_divs").removeClass("expanded").addClass("collapsed");
		$("#" + emid).removeClass("collapsed").addClass("expanded");
		LastLeftID = emid;
		return false;
	},
	//点击body隐藏
	mouseMove : function (ev) {
		ev = ev || window.event;
		var mousePos = Cart_page.mouseCoords(ev);
		var mouseX = mousePos.x;
		var mouseY = mousePos.y;
		var tar = ev.srcElement || ev.target;
		if (tar.id != "ah1") {
			var flag = true;
			if (tar.id == "ChildMenu1") {
				flag = false;
			}
			while (tar.parentNode) {
				tar = tar.parentNode;
				if (tar.id == "ChildMenu1") {
					flag = false;
					break;
				}
			}
			if (flag) {
				var obj = document.getElementById('ChildMenu1');
				if (obj!=null&&obj.className.toLowerCase() == "expanded") {
					obj.className = "collapsed";
				}
			}
		}
	},
	mouseCoords : function (ev) {
		if (ev.pageX || ev.pageY) {
			return {
				x : ev.pageX,
				y : ev.pageY
			};
		}
		return {
			x : ev.clientX + document.documentElement.scrollLeft
					- document.body.clientLeft,
			y : ev.clientY + document.documentElement.scrollTop
					- document.body.clientTop
		};
	}
}